package com.jishucai.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * @author admin
 */
public class SomeClientHandler extends ChannelInboundHandlerAdapter {

    private String message = "hello world";


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }

    /**
     * 当channel被激活
     * @param ctx
     * @throws Exception
     */
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
//        ctx.channel().writeAndFlush(message);
//        ctx.channel().writeAndFlush(message);

        for (int i = 0 ; i < 100 ; i++) {
            ctx.channel().writeAndFlush(message);
        }
    }
}
